
using System;

namespace Serpis
{
	public static class PersisterFactory
	{
		public static IPersister NewPersister(Type type)
		{
			if (!type.IsDefined(typeof(PersisterAttribute), true))
				return new Persister();
			
			PersisterAttribute persisterAttribute = (PersisterAttribute)Attribute.GetCustomAttribute(type, typeof(PersisterAttribute));
			return (IPersister)Activator.CreateInstance(persisterAttribute.PersisterType);
		}
	}
}
